// Code scaffolded by goctl. Safe to edit.
// goctl 1.9.1

package file

import (
	"audio-server/internal/model"
	"audio-server/internal/result"
	"context"

	"audio-server/internal/svc"
	"audio-server/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type FileDeleteLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewFileDeleteLogic(ctx context.Context, svcCtx *svc.ServiceContext) *FileDeleteLogic {
	return &FileDeleteLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *FileDeleteLogic) FileDelete(req *types.FileDeleteReq) (resp *types.BaseMsgResp, err error) {
	// todo: add your logic here and delete this line
	id := req.FileId
	fileModel := model.NewSysFileModel(l.svcCtx.Conn)
	err = fileModel.Delete(l.ctx, id)
	if err != nil {
		return result.Fail("删除失败"), nil
	}

	return result.Success("删除成功"), nil
}
